using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.ApplicationBlocks.Data;
using Microsoft.AceEngineering.SPM.SPMBusinessLayer;

public partial class Controls_LifeCycleGraphics : System.Web.UI.UserControl
{
    public void LoadAppStatus(int iAppId)
    {
        rptImages.DataSource = WTRIAssessmentBL.dsLoadAssessmentDataSet("SPM_spGetAppLifeCyclesStatusByAppID", iAppId);
        rptImages.DataBind();

        Repeater rptI = (Repeater)FindControl("rptImages");

        if (ValidateAssessmentTaken(iAppId))
        {
            lblRIAStatus.Text = "<a href=\"" + Request.ApplicationPath + "/Workflow/Default.aspx?id=" + iAppId + "\">Completed</a>";
            if (rptI.Items.Count != 0)
            {
                lblUTSStatus.Text = "<a href=\"" + Request.ApplicationPath + "/Workflow/Tasks.aspx?id=" + iAppId + "\">Completed</a>";
                foreach (RepeaterItem ri in rptI.Items)
                {
                    HyperLink htmlTask = (HyperLink)ri.FindControl("lnkTasks");
                    htmlTask.NavigateUrl = Request.ApplicationPath + "/Workflow/Tasks.aspx?ID=" + iAppId + "";
                    HiddenField hfStatus = (HiddenField)ri.FindControl("hfStatus");
                    if (hfStatus.Value == "red")
                    {
                        lblUTSStatus.Text = "<a href=\"" + Request.ApplicationPath + "/Workflow/Tasks.aspx?id=" + iAppId + "\">In Progress</a>";
                    }
                }
            }
            else
            {
                lblUTSStatus.Text = "<a href=\"" + Request.ApplicationPath + "/Workflow/Tasks.aspx?id=" + iAppId + "\">No tasks were assigned for the score range this application generated.</a>";
            }
        }
        else
        {
            lblRIAStatus.Text = "<a href=\"" + Request.ApplicationPath + "/Workflow/Default.aspx?id=" + iAppId + "\">In Progress</a>";
            lblUTSStatus.Text = "<a href=\"" + Request.ApplicationPath + "/Workflow/Tasks.aspx?id=" + iAppId + "\">The responses for this application have not been submitted and no tasks have been generated.</a>";
        }

    }

    private bool ValidateAssessmentTaken(int intAppID)
    {
        int score = WTRIAssessmentBL.GetValidateScoreExist(intAppID);
        if (score == -1)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}